const { ListToNode, NodeToList, ListNode, timeL } = require("../utils.js");
/**
 * @param {number} m
 * @param {number} n
 * @return {number}
 */
var uniquePaths = function (m, n) {
  let res = 0;
  if (m === 1 || n === 1) return 1;
  if (m === 2 || n === 2) return Math.max(m, n);
  const fun = (m, n) => {
    if (m === 3 || n === 3) {
      let val = Math.max(m, n);
      res += (val * (val + 1)) / 2;
    } else {
      if (m) fun(m - 1, n);
      if (n) fun(m, n - 1);
    }
  };
  fun(m, n);
  return res;
};
/**
 4   5   6   7    8   9    10   11   12
20  35  56  84  120  165  220  286  364
 5   7  9/2  12  15  18/3  22   26   30/4
 */
// n * (n+1) / 2
let m = 4,
  n = 12;
timeL(uniquePaths, [m, n]);
